<?php

defined('SYSPATH') OR die('No direct access allowed.');

class Welcome_Controller extends Template_Controller {

    const ALLOW_PRODUCTION = FALSE;

    public $template = 'kohana/template';

    public function index() {

        $this->template->titulo = 'Página Inicial | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->js_lib = 'mootools';
        $this->template->content_1 = new view('cont_dinamico/slider');
        $this->template->content_2 = new view('cont_dinamico/ul_intro');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            "
              <script type='text/javascript'> 

              jQuery.noConflict();
              
              (function($) {
                $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
              })(jQuery);  
              
              </script>
                
             ",
            '<script type="text/javascript" src="' . url::base(false) . 'js/mootools.js"></script>',
            '<script type="text/javascript" src="' . url::base(false) . 'js/default.js"></script>'
        );
    }

    public function contato() {

        
        $is_sent = false;
        
        if( isset ($_POST['submit']) ){
            
            $is_sent = true;
            
            $para = 'reservas@pontadomadeiro.com.br';
            $nome = $_POST['nome'];
            $email = $_POST['email'];
            $assunto = $_POST['assunto'];
            $mensagem = $_POST['mensagem'];
            
            $html = 
            '
                <!DOCTYPE html>
                <html>
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                        <title></title>

                        <style type="text/css">
                            *{margin: 0;padding: 0;font-family: arial}

                        .table1{width: 500px;background: #DED5AC;}

                        .table1 thead tr th{
                            background: #C5BB8E;
                            color: #6E6345;
                            padding: 5px;
                            font-weight: normal;
                            font-size: 20px;
                            }
                        .table1 tbody tr td{

                            }

                            .table2{
                                background: #DED5AC;
                                width: 500px;
                                margin: -2px 0 0 0;
                            }

                            .table2 thead tr th{
                            font-weight: normal;
                            text-align: left; 
                            width: 130px!important;
                            display: block;
                            padding: 10px;
                            float: left;
                            background: #C5BB8E;
                            color: #6E6345;
                            margin-top: 2px;
                            }
                            .table2 thead tr td{
                            display: block;
                            padding: 10px;               
                            width: 321px;
                            float: right;
                            background: #C5BB8E;
                            color: #6E6345;
                            margin-top: 2px;
                            }            
                        </style>

                    </head>
                    <body>
                        <table class="table1">
                            <thead>
                                <tr>
                                    <th>
                                        Contato do site
                                    </th>
                                </tr>
                            </thead>
                        </table>

                        <table class="table2">
                            <thead>
                                <tr>
                                    <th>
                                        Nome:
                                    </th>    
                                    <td>
                                        '."$nome".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Email:
                                    </th>                    
                                    <td>
                                        '."$email".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Assunto:
                                    </th>                 
                                    <td>
                                        '."$assunto".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Mensagem:
                                    </th>                                                     
                                    <td>
                                        '."$mensagem".'
                                    </td>
                                </tr>
                            </thead>           
                        </table>
                    </body>
                </html>
            ';
          
                                                            
            email::send($para, 'Contato do site', $assunto, $html, TRUE);
            
        }
        
        $this->template->js_lib = 'jquery-1.6.4';
        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'Contato | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/contato');
        $this->template->content_2 = new view('cont_dinamico/form_contato');
        $this->template->google_maps_script = new view('scripts/google_maps');
        $this->template->content_2->return_sentmail = $is_sent;
        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery.validate.js"></script>',
            '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>',
            "
            <script> 
                $(document).ready(function () { 
                
                    $('#form-contato').validate({
                        
                       rules:{
                         email: {
                          required: true,
			  email: true
                         },
                       },
                       messages:{
                         email: 'Por favor, informe um email válido.'
                       }

                    });

                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script> 
            "
        );
    }

    public function hotel() {

        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'O Hotel | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/hotel-1');
        $this->template->content_2 = new view('cont_dinamico/blank-page');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            "
              <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script>
                
             "
        );
    }

    public function servicos() {

        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'Serviços | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/servicos');
        $this->template->content_2 = new view('cont_dinamico/blank-page');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            "
            <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script> 
            "
        );
    }

    public function reservas() {
               
        $is_sent = false;
        
        $this->template->js_lib = 'jquery-1.6.4';
        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'Reservas | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/form_reservas');
        $this->template->content_2 = new view('cont_dinamico/blank-page');        
                       
        
        if( isset ($_POST['submit']) ){
            
            $is_sent = true;
            
            $para = 'reservas@pontadomadeiro.com.br';
            
            $nome = $_POST['nome'];
            $telefone = $_POST['telefone'];
            $email = $_POST['email'];
            $cidade = $_POST['cidade'];
            $pais = $_POST['pais'];
            $estado = $_POST['estado'];
            $entrada = $_POST['entrada'];
            $saida = $_POST['saida'];
            $n_de_pessoas = $_POST['n_de_pessoas'];
            $tipo_de_acomodacao = $_POST['tipo_acomodacao'];
            $traslado = $_POST['traslado'];
            $mensagem = $_POST['mensagem'];
            
            $html = 
            '
                <!DOCTYPE html>
                <html>
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                        <title></title>

                        <style type="text/css">
                            *{margin: 0;padding: 0;font-family: arial}

                        .table1{width: 500px;background: #DED5AC;}

                        .table1 thead tr th{
                            background: #C5BB8E;
                            color: #6E6345;
                            padding: 5px;
                            font-weight: normal;
                            font-size: 20px;
                            }
                        .table1 tbody tr td{

                            }

                            .table2{
                                background: #DED5AC;
                                width: 500px;
                                margin: -2px 0 0 0;
                            }

                            .table2 thead tr th{
                            font-weight: normal;
                            text-align: left; 
                            width: 130px!important;
                            display: block;
                            padding: 10px;
                            float: left;
                            background: #C5BB8E;
                            color: #6E6345;4
                            margin-top: 2px;
                            }
                            .table2 thead tr td{
                            display: block;
                            padding: 10px;               
                            width: 321px;
                            float: right;
                            background: #C5BB8E;
                            color: #6E6345;
                            margin-top: 2px;
                            }            
                        </style>

                    </head>
                    <body>
                        <table class="table1">
                            <thead>
                                <tr>
                                    <th>
                                        Solicitacao de Reserva
                                    </th>
                                </tr>
                            </thead>
                        </table>

                        <table class="table2">
                            <thead>
                                <tr>
                                    <th>
                                        Nome:
                                    </th>    
                                    <td>
                                        '."$nome".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Email:
                                    </th>                    
                                    <td>
                                        '."$email".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Telefone:
                                    </th>                 
                                    <td>
                                        '."$telefone".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Cidade:
                                    </th>
                                    <td>
                                        '."$cidade".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        País:
                                    </th>
                                    <td>
                                        '."$pais".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Estado:
                                    </th>
                                    <td>
                                        '."$estado".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Entrada:
                                    </th>
                                    <td>
                                        '."$entrada".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Saida:
                                    </th>
                                    <td>
                                        '."$saida".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Numero de Pessoas:
                                    </th>
                                    <td>
                                        '."$n_de_pessoas".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Tipo de Acomodacao:
                                    </th>
                                    <td>
                                        '."$tipo_de_acomodacao".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Traslado:
                                    </th>
                                    <td>
                                        '."$traslado".'
                                    </td>
                                </tr>
                                <tr>
                                    <th>
                                        Mensagem:
                                    </th>
                                    <td>
                                        '."$mensagem".'
                                    </td>
                                </tr>
                            </thead>           
                        </table>
                    </body>
                </html>
            ';
                                                                      
            email::send($para, 'Contato do Site', 'Solicitacao de Reserva', $html, TRUE);
                       
        }
        
        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery.dropkick.js"></script>',
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery.validate.js"></script>',
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery.maskedinput-1.3.min.js"></script>',
            '<script type="text/javascript" charset="utf-8">
              $(function () {
                $(".default").dropkick();     
              });
            </script>',
            "
            <script> 
                $(document).ready(function () { 
                
                    $('#form-reservas').validate({
                    
                      rules:{
                         
                        email: {
                           required: true,
                           email: true
                        }
                         
                      },
                        
                       messages:{
                       
                         email: {
                            email:'Por favor, informe um email válido.'
                         }
                         
                       }
                       
                    });
                    
                    
                      $('.data').mask('99/99/9999');
                      $('#telefone').mask('(99) 9999-9999');
                     

                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script> 
            "
        );
        
        $this->template->content_1->return_sentmail = $is_sent;
        $this->template->extra_css_files = array(
            '<link rel="stylesheet" href="' . url::base(false) . 'css/dropkick.css"/>'
        );
    }

    public function gastronomia() {

        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'Gastronomia | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/gastronomia');
        $this->template->content_2 = new view('cont_dinamico/blank-page');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            "
            <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script> 
            "
        );
    }

    public function responsabilidade_socioambiental() {

        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'Responsabilidade Socioambiental | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/responsabilidade_socioambiental');
        $this->template->content_2 = new view('cont_dinamico/blank-page');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            '<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>',
            "
            <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script> 
            "
        );
    }

    public function passeio() {

        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'Passeio | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/passeio');
        $this->template->content_2 = new view('cont_dinamico/blank-page');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            "
              <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script>
                
             "
        );
    }

    public function destino() {

        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'O Destino | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/o-destino');
        $this->template->content_2 = new view('cont_dinamico/blank-page');

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            "
              <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script>
                
             "
        );
    }

    public function acomodacao($acomodacao) {

        $acomodacao_model = new Acomodacao_Model();

        $configuracoes = $acomodacao_model->action($acomodacao);


        $this->template->header = new view('default_1/topo');
        $this->template->footer = new view('default_1/rodape');
        $this->template->titulo = 'O Hotel | Hotel Ponta do Madeiro - Magia, Beleza e Encanto neste maravilhoso lugar de golfinhos e tartarugas marinhas!';
        $this->template->content_1 = new view('cont_dinamico/acomodacao');
        $this->template->content_2 = new view('cont_dinamico/blank-page');


        $this->template->content_1->titulo = $configuracoes['titulo'];
        $this->template->content_1->texto = $configuracoes['texto'];
        $this->template->content_1->fotos = $configuracoes['fotos'];

        $this->template->js_links = array(
            '<script type="text/javascript" src="' . url::base(false) . 'js/jquery-1.7.2.js"></script>',
            '<script type="text/javascript" src="' . url::base(false) . 'js/lightbox.js"></script>',
            "
              <script> 
                $(document).ready(function () { 
                    $('#dropdown li').hover(
                        function () {
                        //show its submenu
                          $('ul', this).slideDown(100);

                        },
                        
                        function () {
                            //hide its submenu
                            $('ul', this).slideUp(100);         
                        }
                    );
                 });
              </script>
                
             "
        );

        $this->template->extra_css_files = array(
            '<link rel="stylesheet" href="' . url::base(false) . 'css/lightbox.css"/>'
        );
    }

    public function __call($method, $arguments) {

        $this->auto_render = FALSE;

        echo 'This text is generated by __call. If you expected the index page, you need to use: welcome/index/' . substr(Router::$current_uri, 8);
    }

}